﻿function editSettings() {
	if (refreshTab('editSettings')) return;

	var title = new Ext.form.TextField({
				fieldLabel : 'Title',
				name : 'title',
				allowBlank : false,
				value : sys.settings.title
			});
	var copyRight = new Ext.form.TextField({
				fieldLabel : 'CopyRight',
				name : 'copyright',
				allowBlank : false,
				value : sys.settings.copyright
			});
	var openAcc = new Ext.form.Checkbox({
				boxLabel : '开放访问',
				name : 'openAccess',
				checked : sys.settings.openAccess
			});
	var openosreg = new Ext.form.Checkbox({
				boxLabel : '开放校外注册',
				name : 'openOutsideReg',
				checked : sys.settings.openOutsideReg
			});
	var openosmsg = new Ext.form.Checkbox({
				boxLabel : '开放校外发信息',
				name : 'openOutsideSendMsg',
				checked : sys.settings.openOutsideSendMsg
			});
	var opendisc = new Ext.form.Checkbox({
				boxLabel : '开放讨论',
				name : 'openDiscuss',
				checked : sys.settings.openDiscuss
			});
	var openosdisc = new Ext.form.Checkbox({
				boxLabel : '开放校外发讨论',
				name : 'openOutsideDiscuss',
				checked : sys.settings.openOutsideDiscuss
			});
	var lang = new Ext.Button({
				text : '编程语言管理',
				handler : function() {
					editLang();
				}
			})

	var toolbar = new Ext.Toolbar({
				items : [new Ext.Button({
									text : '取消',
									iconCls : 'cancel-icon',
									handler : function() {
										closeTab('editSettings');
									}
								}), new Ext.Button({
									text : '保存',
									iconCls : 'ok-icon',
									handler : onsave
								})]
			});
	var form = new Ext.FormPanel({
				id : 'editSettings',
				title : 'Settings',
				labelAlign : 'right',
				labelWidth : 70,
				autoScroll : true,
				closable : true,
				defaults : {
					anchor : '98%'
				},
				bodyStyle : 'padding: 20px 40px 20px 20px',
				items : [title, copyRight, openAcc, openosreg, openosmsg, opendisc, openosdisc, {
							style : 'padding-left:75px;padding-top:5px',
							border : false,
							items : lang
						}],
				fbar : toolbar
			});
	addTab(form);

	function onsave() {
		if (!form.getForm().isValid()) {
			alertx('请正确输入数据！');
			return;
		}
		ajaxform({
					form : form,
					url : url.editSystemSettings,
					success : function() {
						alertx('配置修改成功！');
						refreshMainPage();
						closeTab('editSettings');
					}
				});
	}
}